<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2019/2/26
 * Time: 13:59
 */

namespace App\Model;


use Illuminate\Database\Eloquent\Model;

class Company extends Model
{
    public $table = 'company';

    //查询所有数据
    public function getAll()
    {
        return $this->get()->toArray();
    }

    //查询热门企业
    public function getHot()
    {
        return $this->where(['is_hot'=>1])->get()->toArray();
    }

    //登录后获取公司企业id，并查询出信息
    public function findOne($id){
        return $this->get()->where('id',$id)->toArray();
    }
    //修改企业资料
    public function updComp($name,$address,$credit_code,$email,$guimo,$id,$image,$industry_id,$tag,$time){
        return $this->where('id',$id)->update(['name'=>$name,'image'=>$image,'tag'=>$tag,'credit_code'=>$credit_code,'address'=>$address,'email'=>$email,'guimo'=>$guimo,'industry_id'=>$industry_id,'updated_at'=>$time]);
    }


    //注册时默认添加一条公司信息
    public function addCompany($image,$name,$is_hot,$tag,$credit_code,$address,$created_at,$updated_at,$num)
    {
        return $this->insert(['image'=>$image,'name'=>$name,'is_hot'=>$is_hot,'tag'=>$tag,'credit_code'=>$credit_code,'address'=>$address,'created_at'=>$created_at,'updated_at'=>$updated_at,'num'=>$num]);
    }

}
